package day01;

/**
 * @author feng
 * @Date 2021/10/14 9:12
 * 饿汉式(静态常量)
 */
class SingletonTest {
    public static void main(String[] args) {

        Singleton instance = Singleton.getInstance();
        System.out.println(instance);
    }

}

class Singleton{
    //私有构造器
    private Singleton(){}
    //创建实例
    private final static Singleton singleton = new Singleton();

    //提供静态对外的方法，返回实例
    public static Singleton getInstance(){
        return singleton;
    }


}